package com.example.hxds.mps.controller;

import com.example.hxds.common.util.R;
import com.example.hxds.mps.controller.form.CalculateDriveLineForm;
import com.example.hxds.mps.controller.form.EstimateOrderMileageAndMinuteForm;
import com.example.hxds.mps.service.MapService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;

/**
 * @ClassName: MapController
 * @Description: 地图模块Web接口
 * @Author: 丛雨
 * @Date: 2024/1/25 20:35
 */
@RestController
@RequestMapping("/map")
@Tag(name = "MapController", description = "地图模块Web接口")
public class MapController {
    @Resource
    private MapService mapService;

    @PostMapping("/estimateOrderMileageAndMinute")
    @Operation(summary = "预估里程和时间")
    public R estimateOrderMileageAndMinute(@RequestBody @Valid EstimateOrderMileageAndMinuteForm form) {
        HashMap result = mapService.estimateOrderMileageAndMinute(form.getMode(), form.getStartPlaceLatitude(), form.getStartPlaceLongitude(), form.getEndPlaceLatitude(), form.getEndPlaceLongitude());
        return R.ok().put("result", result);
    }

    @PostMapping("/calculateDriveLine")
    @Operation(summary = "路线规划")
    public R calculateDriveLine(@RequestBody @Valid CalculateDriveLineForm form) {
        HashMap result = mapService.calculateDriveLine(form.getStartPlaceLatitude(), form.getStartPlaceLongitude(), form.getEndPlaceLatitude(), form.getEndPlaceLongitude());
        return R.ok().put("result", result);
    }
}
